Loop between dates

  • Code
    
    
                                  $startDate = date("Y-m-01", strtotime($row->from_date));
                                  $endDate = date("Y-m-d");
                                  while($startDate <= $endDate){
                                        $dueYear=date("Y", strtotime($startDate));
                                        $dueMonth=date("m", strtotime($startDate));
                                        
                                        $dueCount=DueReport::where('student_id', $input['student_id'])->where('status','!=','cancelled')->where('subject_id',$row->subject_id )->whereYear('date',$dueYear )->whereMonth('date',$dueMonth)->count();
                                        .... 
                                        .... 
                                        
                                        $startDate=date("Y-m-d", strtotime("+1 month", strtotime($startDate)));                             
                                  }